{extend name="public/base"}

{block name="title"}就行天下-防伪{/block}

{block name="style"}
<link rel="stylesheet" href="__STATIC__/home/css/index.css" />
<style>
    .shipment{
        display: flex;
        flex-direction: row;
        position: absolute;
        bottom: 0;
    }
    .shipment_btn{
        background: #C40202;
        border-radius: 7px;
        padding: .1rem 1rem;
    }
    .shipment p{
        margin-top: .2rem;
        margin-left: .5rem;
    }
    .confirmOrder .weui-cell__bd.shipment_main {
        bottom: 10px;
    }
</style>
{/block}



{block name="main"}
<div class="pageControl lookIndent bg-f7">
    <div class="main-top"></div>
    <div class="msui_nav msui_navTop">
        <h1 class="msui_navTop-title">相关订单</h1>
        <a href="" class="msui_navTop-right msui_navTop-cnav"><i class="micon-cnav"></i></a>
    </div>
    <div class="indent-top">
        {volist name="shop_orders" id="order"}
        <div class="lookIndent-list">
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <p class="fs07">{$order->shop->name}</p>
                    <div class="my-flex1 cl-9999 fs065">
                        订单编号: <span>{$order->order_sn}</span>
                    </div>
                </div>
            </div>
            {volist name="order.product" id="p"}
            <div class="weui-cell confirmOrder">
                <div class="weui-cell__hd">
                    <img src="__STATIC__/home/images/product1.png" alt="">
                </div>
                <div class="weui-cell__bd shipment_main" style="right: 15px;">
                    <p class="fs06 listFont">{$p.name}</p>
                    {eq name="p.me|default='0'" value="1"}
                    <div class="shipment">
                        {lt name="p.shipped_num" value="$p.num"}
                        <a href="javascript:;" class="cl-f shipment_btn" data-order-id="{$order.id}" data-order-product-id="{$p.id}">出货 </a>
                        {/lt}
                        {gt name="p.shipped_num" value="0"}
                        <p>已出货<span>{$p.shipped_num}瓶</span></p>
                        {/gt}
                    </div>
                    {/eq}
                </div>
                <div class="weui-cell__ft fs06">
                    <p>￥{$p.price}</p>
                    <p>x{$p.num}</p>
                </div>
            </div>
            {/volist}
        </div>
        {/volist}
</div>
{/block}

{block name="javascript"}
<script>
$(function () {
    $('.shipment_btn').click(function () {
        var _this = $(this);
        $.confirm('确定出货？', function () {
            $.ajax({
                type : 'POST',
                url : '{:url("shipment")}',
                data : {
                    'shop_id' : '{$shop.id}',
                    'product_id' : '{$product.id}',
                    'code' : '{$code.code}',
                    'order_id' : _this.data('order-id'),
                    'order_product_id' : _this.data('order-product-id')
                },
                dataType : 'json',
                success : function (msg) {
                    if (msg.code == 200) {
                        $.toptip('出货成功！', 'success')
                        setTimeout(function () {
                            window.location.reload();
                        }, 1000);
                    } else {
                        $.toptip(msg.msg)
                    }
                    console.log(msg)
                }
            });
        });

    });
});
</script>
{/block}